import './manifest';
import Main from './src/main';
import WXLoadPlugin from './libs/pixi/WXLoadPlugin';

const systemInfo = wx.getSystemInfoSync();
const {pixelRatio, windowWidth, windowHeight, platform} = systemInfo

// 三个屏幕模式 fixedWidth, fixedHeight, default
// scaleMode 需要根据项目来定,一般竖屏是 fixedWidth=640, 横屏fixedHeight=640;
let scaleMode = 'fixedWidth'
let width = windowWidth * pixelRatio;
let height = windowHeight * pixelRatio;
let baseValue = 640;
if (scaleMode == 'fixedWidth') {
    const baseWidth = baseValue;
    width = baseWidth;
    height = baseWidth * (windowHeight / windowWidth);
} else if (scaleMode == 'fixedHeight') {
    const baseHeight = baseValue;
    width = baseHeight * (windowWidth / windowHeight);
    height = baseHeight;
} 
width = Math.ceil(width);
height = Math.ceil(height);
const scaleX = width / windowWidth;
const scaleY = height / windowHeight;
PIXI.interaction.InteractionManager.prototype.mapPositionToPoint = (point, x, y) => {
    point.x = x * scaleX;
    point.y = y * scaleY;
}

let options = {
    width, 
    height, 
    backgroundColor:0x25284A,
    view:canvas
};

console.log("baseurl:", PIXI.loader.baseUrl);
console.log("width:", width);
console.log("height:", height);
let app = new PIXI.Application(options);

const main = new Main(app);
app.stage.addChild(main);